import shaw.wifi.server.ShawWifiMessage;
import junit.framework.TestCase;


public class TestWifiMessage extends TestCase {
	private ShawWifiMessage msg;
	
	public void testMsg() {
		msg = new ShawWifiMessage(2);
		
		msg.type = 3;
		
		msg.header[0] = "abc";
		msg.data[0] = "def".getBytes();
		
		msg.header[1] = "qed";
		msg.data[1] = "nan".getBytes();
		
		assertEquals(msg.length, 2);
		
		byte[] bts = msg.toByteArray();
		
		ShawWifiMessage readByte = ShawWifiMessage.fromByteArray(bts);
		
		assertEquals(readByte.length, 2);
		assertEquals(readByte.type, 3);

		assertEquals(readByte.header[0], "abc");
		assertEquals(new String(readByte.data[0]), "def");
		
		assertEquals(readByte.header[1], "qed");
		assertEquals(new String(readByte.data[1]), "nan");
	}
}
